package com.sicong.admin.controller;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sicong.admin.entity.Log;
import com.sicong.admin.service.LogService;
import com.sicong.common.core.utils.Result;
import com.sicong.common.core.utils.ResultUtil;
//import com.sicong.common.security.annotation.Inner;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 日志表 前端控制器
 * </p>
 *
 * @author chenww
 * @since 2020-12-22
 */
@Api(tags = {"日志控制器"})
@RestController
@RequestMapping("/log")
public class LogController {

    @Resource
    private LogService logService;

    @ApiOperation("分页查询日志")
    @GetMapping("/page")
    public Result<Page<Log>> getLogPage(Page<Log> page, Log log) {
        return ResultUtil.success(logService.page(page, Wrappers.query(log)));
    }

    @ApiOperation("删除日志")
    @DeleteMapping("/{ids}")
    public Result<Void> removeById(@ApiParam("日志id") @PathVariable String ids) {
        logService.removeById(ids.split(","));
        return ResultUtil.success();
    }

//    @Inner
    @ApiOperation("插入日志")
    @PostMapping("/save")
    public Result<Void> save(@RequestBody Log log) {
        logService.save(log);
        return ResultUtil.success();
    }

}

